<?php 
    if(count($lotes) == 0):

        echo lang_system('no_data');
    else:
    
?>

<?php echo $info_habilitacao; ?>

<div class="col-xs-4 col-md-3 col-sm-6 sidebar-cat">
	<div class="text-categ">
		<span class="header-categoria">CATEGORIAS</span>
	</div>
	<?php if(count($count_categories) > 0):?>
	<ul class="filter-categorias filter">
	    <?php foreach ($count_categories as $categorie):?>
		<li class="item">
		 <a class="item-header" href="javascript:void(0)"> <i class="ico-float"><img
					src="/public/images/icones/<?php echo $categorie->SLUG ?>.png"></i> 
					
					<span class="item-label"><?php echo $categorie->NAME?> <em
					class="total-by-categorie"><?php echo  $categorie->TOTAL;?></em></span>
		 </a>
		 <div class="clearfix"></div>
		  <ul class="filter-box">
		     <?php if(count($categorie->SUB_CATEGORIES) > 0):?>
		      <li class="categoria-filter"><span>Categoria</span></li> 
                      <div class="box-checkbox">
		              <?php foreach ($categorie->SUB_CATEGORIES as $row):?>
		              <li class="categoria-filter-item" >
		              <div class="checkbox">
			             <label> <input data-trigger  url="<?php echo site_url('lotes/' . $categorie->SLUG.'/'.$row->SLUG)?>" type="checkbox"> <?php echo $row->NAME;?>
			           </label>
		               </div>
                      
		              </li>
                              </div>
		              <?php endforeach;?>
		     <?php endif;?>
		              
		  
		  </ul> 
		
		</li>
       <?php endforeach;?>
	</ul>
	<?php endif;?>
	     <?php if(count($count_estados) > 0):?>

         <?php $uf_total = 0;?>
    <div class="filter-box">
         <div class="categoria-filter">
		 <span>Estados</span>
   	     </div>
             <div class="box-checkbox">
	        <ul class="menu-filter-estados">
            <?php foreach ($count_estados as $row):?>
            <li><a href="<?php echo site_url('lotes/todos/todos/localizados-em-' . $row->UF); ?>"><?php echo $row->NOME;?> (<?php echo $row->TOTAL;?>)</a></li>
            <?php $uf_total+= $row->TOTAL;?>

            <?php endforeach;?>
            </ul>
             </div>
    </div>
	       <div class="box-total-lotes-all-country">
		   <span>TOTAL DE LOTES EM LEILÃO </span> <span class="num-all-country"><?php echo $uf_total;?></span>
	      </div> 
         <?php endif;?>
    </div>
    <!-- BOX RIGHT -->
<div class="col-xs-8 col-md-9 list-cat-page">


<?php
if (isset ( $data_search )) {
	echo '<div class="row"><div class="col-xs-12 box-text-result-pesquisa"><h3 class="label-search-results">Palavra pesquisada : ' . $data_search . '<span class="pull-right">Total dos dados : ' . count($lotes) . '</span></h3></div></div>';
}
?>

<?php if(count($lotes) > 0): $favoritos_itens = array();?>
  <?php if(count($favoritos_user) > 0){
  	        foreach ($favoritos_user as $fav):
  	        $favoritos_itens[] = $fav->LOTE_ID;
  	        endforeach;   
  }?>
  <?php foreach($lotes as $row):?>
    
    
    
    
       <div class="leilao-lote-item">
           
                <div class="leilao-lotes-img">
                    <div class="leilao-number">
                        <span>LOTE <?php echo $row->NUM_LOTE;?></span>
                        <?php if(userData()->id == 0 ):?>
                          <a show-message-login href="javascript:void()" class="text-click">CLIQUE PARA SEGUIR A OFERTA <i class="fa fa-star-o"></i></a>
                        <?php endif;?> 
                         <?php if(userData()->id > 0 && !in_array($row->ID, $favoritos_itens) ):?>  
                          <a href="<?php echo site_url('addFavoritos/'.$row->ID.'?r='.uri_string()); ?>" class="text-click">DESEJA SEGUIR A OFERTA <i class="fa fa-star-o"></i></a>
                        <?php endif; ?>
                        <?php if(userData()->id > 0 && in_array($row->ID, $favoritos_itens) ):?>  
                           <a href="<?php echo site_url('removeFavoritos/'.$row->ID.'?r='.uri_string()); ?>" class="text-click">SEGUINDO ESTA OFERTA <i class="fa fa-star"></i></a>
                        <?php endif; ?>
                    </div>
                    <a href="<?php echo site_url('detalhes-lote/'.$row->ID.'/'.$row->LEILAO_ID)?>">  
                        <img class="img-thumbs" src="/public/images/lotes/thumbs/<?php echo render_first_image($row->IMAGENS);?>" >
                    </a>  
                </div>
                <div class="box-descricao-lote">
                    <h3><?php echo $row->DESCRICAO;	?></h3>
                    <p><?php echo $row->SUB_DESCRICAO;	?></p>
                    <p>Local: <?php echo $row->LOCALIZACAO .'-'.$row->UF; ?></p>
                    <span class="text-encerramento">Encerramento: <?php echo extract_data($row->FECHAMENTO,'/');?> as <?php echo substr(extract_time($row->FECHAMENTO),0,5); ?></span>
                    <p class="info-comitente-lote">
                    <?php if(!empty($row->LOGO)):?>
                     <i><img src="/public/images/comitentes/<?php echo $row->LOGO;  ?>" width="60px"></i>
                    <?php else:?>
                    <i><img src="/public/images/no_image.jpg" width="60px"></i>
                    <?php endif;?>
                    
                     <?php echo $row->NOME_FANTASIA; ?></p>
                </div>
                <div id="box-destak-valor">
                    <div class="destaque-valor-atual">
                        <h4>Valor Atual</h4>
                        <?php $lance_current = (float) !is_null($row->LAST_LANCE) ? $row->LAST_LANCE : $row->LANCE_INICIAL; ?>
                        <h3>R$ <?php  echo number_format($lance_current,2,',','.'); ?> </h3>
                        <?php 
                        
                       
                          $label_status = Utils::message('lote_opened');
                          $_class_status = 'l-andamento'; 
                          
                            if($row->CLOSED == 'S'){
                              $label_status = Utils::message('lote_closed');
                              $_class_status = 'l-encerrado';
                              
                              
                          }
                        
                          if($row->VENDIDO == 'S'){
                              $label_status = Utils::message('lote_sold');
                              $_class_status = 'l-encerrado';
                              
                              
                          }
                          
                          if($row->VENDIDO == 'N' && $row->CONDICIONAL == 'S'){
                              $label_status = Utils::message('lote_closed_conditional');
                              $_class_status = 'l-encerrado';
                              
                              
                              
                          }
                          
                        
                        ?>
                        
                       
                        
                        <div class="info-status-lote <?php echo $_class_status; ?>">
                            
                            <span class="label-a"><?php echo $label_status; ?></span>
                            <span class="label-b"><i class="fa fa-plus "></i></span>  

                        </div>

                    </div>
                    <div class="box-estatisticas-geral">
                        <div class="box-count">
                            <span>Visitas</span>
                            <span>Compradores</span>
                            <span>Lances</span>
                        </div>
                        <div class="box-count2">
                            <span class="box-count-v"><?php echo (int) $row->VISITAS; ?></span>
                            <span class="box-count-v"><?php echo (int) $row->COMPRADORES;?></span>
                            <span class="box-count-v"><?php echo (int) $row->LANCES;?></span>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                </div>
          
                <div class="clearfix"></div>
                 <a href="<?php echo site_url('detalhes-lote/'.$row->ID.'/'.$row->LEILAO_ID)?>" class="button-response btn btn-lg btn-info btn-block">Detalhes</a>
            </div>

            
  <?php endforeach;?>
<?php endif;?>

</div>
<?php endif;?>

<?php 
add_js('plugins/frontend/jquery.mousewheel.min','footer', 11);
//jquery.jqzoom-core.js
add_js('plugins/frontend/jquery.jqzoom-core','footer', 11);
add_js('plugins/frontend/fancybox/jquery.fancybox','footer',6);
add_js('plugins/frontend/fancybox/jquery.fancybox-buttons','footer', 9);
add_js('plugins/frontend/fancybox/jquery.fancybox-media','footer', 9);
add_js('plugins/frontend/fancybox/jquery.fancybox-thumbs','footer', 9);
add_css('frontend/fancybox/jquery.fancybox','header',13);
add_css('frontend/fancybox/helpers/jquery.fancybox-buttons','header', 14);
add_css('frontend/fancybox/helpers/jquery.fancybox-thumbs','header', 15);
add_css('frontend/jquery.jqzoom','footer', 16);


?>
